<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>View Delete Own Categories</title>
    </h:head>
    <h:body>
        <h:form id="editOwnCategoriesForm" >
            <p:dataTable styleClass="sample" id="table" value="#{categoryBean.categories}" var="cat">
                <f:facet name="header">
                    <h:outputText value="View own categories" />
                </f:facet>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Id" />
                    </f:facet>
                    <h:outputText value="#{cat.id}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Show name" />
                    </f:facet>
                    <h:outputText value="#{cat.name}" />
                </p:column>
                <p:column id="columnOfAction">
                    <f:facet name="header">
                        <h:outputText value="Select Action" />
                    </f:facet>
                    <h:panelGrid columns="3">
                        <p:column>
                            <p:commandButton  id="editCategoryButton" value="Edit" update="editCategoryForm" action="#{categoryBean.retrieveSelectedCategory(cat.id)}" oncomplete="dEditCategory.show()"/>                
                        </p:column>
                        <p:column>
                            <p:commandButton  id="deleteCategoryButton" update="editOwnCategoriesForm" value="Delete" action="#{categoryBean.deleteSelectedCategory(cat.id)}" />                
                        </p:column>
                    </h:panelGrid>
                </p:column>
            </p:dataTable>
        </h:form>
    </h:body>
</html>

